package com.thti.mecool.client.activity;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

import com.thti.mecool.client.base.BaseActivity;
import com.thti.mecool.client.base.Cache;
import com.thti.mecool.client.model.biz.ProjectBizImpl;
import com.thti.mecool.client.model.biz.TaskBizImpl;
import com.thti.mecool.client.model.po.Project;
import com.thti.mecool.client.model.po.Task;
import com.thti.mecool.client.util.TimeUtil;
import com.thti.mecool.client.widget.ListWidget;
import com.thti.mecool.client.widget.Toolbar;

public class TaskdoneDetailActivity extends BaseActivity {
	private Toolbar toolbar;
	private ImageButton cancel,upload;
	
	OnClickListener MyOnClickListener = new OnClickListener() {
		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.mecool_task_done_detail_upload:
				
				break;
			default:
				finish();
				break;
			}
		}
	};
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		noTitle();
		setContentView(R.layout.mecool_task_done_detail);
		Cache.add(this);
		cancel=(ImageButton)findViewById(R.id.mecool_task_done_detail_cancel);
		upload=(ImageButton)findViewById(R.id.mecool_task_done_detail_upload);
		cancel.setOnClickListener(MyOnClickListener);
		upload.setOnClickListener(MyOnClickListener);
		
		ArrayList<String> listTag = new ArrayList<String>();
		ArrayList<ArrayList<HashMap<String, String>>> taskList = new ArrayList<ArrayList<HashMap<String, String>>>();
		Intent i = getIntent();
		Bundle data = i.getExtras();
		TaskBizImpl taskBizImpl=new TaskBizImpl(this);
		List<Task> list=taskBizImpl.findTaskDetail(TimeUtil.dateToString(new Date(), 1),String.valueOf(getCurrentUser().getId()));
		for(Task s:list){
			System.out.println(s.getPlanId());
			listTag.add(s.getProjectName());
			HashMap<String, String> map=new HashMap<String, String>();
			map.put("time", s.getStartTime()+" - "+s.getEndTime());
			map.put("addr", s.getStoreName());
			map.put("name", s.getTaskName());
			map.put("isType", s.getIsType());
			ArrayList<HashMap<String, String>> arrlist=new ArrayList<HashMap<String,String>>();
			arrlist.add(map);
			taskList.add(arrlist);
		}
		System.out.println(listTag);
		
		new ListWidget(this, taskList, listTag);
	}
	@Override
	protected void onResume() {
		super.onResume();
		toolbar = new Toolbar(this);
		Toolbar.left_btn.setOnClickListener(MyOnClickListener);
		Toolbar.right_btn.setVisibility(8);
		toolbar.setimage(Toolbar.left_btn, R.drawable.mecool_go_back);
		toolbar.setToolbarCentreText("任务完成情况汇报");
	}

}
